package com.ktgj.train.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ktgj.train.service.ITrainOrderitemstatusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.train.domain.TrainOrderitemstatus;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 子订单状态Controller
 * 
 * @author ruoyi
 * @date 2021-11-29
 */
@ControllerAdvice
@RestController
@RequestMapping("/orderitemstatus")
public class TrainOrderitemstatusController extends BaseController
{
    @Autowired
    private ITrainOrderitemstatusService trainOrderitemstatusService;

    /**
     * 查询子订单状态列表
     */
    @PreAuthorize(hasPermi = "train:orderitemstatus:list")
    @GetMapping("/list")
    public TableDataInfo list(TrainOrderitemstatus trainOrderitemstatus)
    {
        startPage();
        List<TrainOrderitemstatus> list = trainOrderitemstatusService.selectTrainOrderitemstatusList(trainOrderitemstatus);
        return getDataTable(list);
    }

    /**
     * 导出子订单状态列表
     */
    @PreAuthorize(hasPermi = "train:orderitemstatus:export")
    @Log(title = "子订单状态", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TrainOrderitemstatus trainOrderitemstatus) throws IOException
    {
        List<TrainOrderitemstatus> list = trainOrderitemstatusService.selectTrainOrderitemstatusList(trainOrderitemstatus);
        ExcelUtil<TrainOrderitemstatus> util = new ExcelUtil<TrainOrderitemstatus>(TrainOrderitemstatus.class);
        util.exportExcel(response, list, "子订单状态数据");
    }

    /**
     * 获取子订单状态详细信息
     */
    @PreAuthorize(hasPermi = "train:orderitemstatus:query")
    @GetMapping(value = "/{orderitemstatus}")
    public AjaxResult getInfo(@PathVariable("orderitemstatus") Long orderitemstatus)
    {
        return AjaxResult.success(trainOrderitemstatusService.selectTrainOrderitemstatusById(orderitemstatus));
    }

    /**
     * 新增子订单状态
     */
    @PreAuthorize(hasPermi = "train:orderitemstatus:add")
    @Log(title = "子订单状态", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TrainOrderitemstatus trainOrderitemstatus)
    {
        return toAjax(trainOrderitemstatusService.insertTrainOrderitemstatus(trainOrderitemstatus));
    }

    /**
     * 修改子订单状态
     */
    @PreAuthorize(hasPermi = "train:orderitemstatus:edit")
    @Log(title = "子订单状态", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TrainOrderitemstatus trainOrderitemstatus)
    {
        return toAjax(trainOrderitemstatusService.updateTrainOrderitemstatus(trainOrderitemstatus));
    }

    /**
     * 删除子订单状态
     */
    @PreAuthorize(hasPermi = "train:orderitemstatus:remove")
    @Log(title = "子订单状态", businessType = BusinessType.DELETE)
	@DeleteMapping("/{orderitemstatuss}")
    public AjaxResult remove(@PathVariable Long[] orderitemstatuss)
    {
        return toAjax(trainOrderitemstatusService.deleteTrainOrderitemstatusByIds(orderitemstatuss));
    }
}
